********************************************************************************************************************************
***   Replication file for tables and figures in:                                                                            
***   Rafiee Rad, S., Braun, S. T., and Roy, O. (2023). Anchoring as a Structural Bias of Deliberation.					     
***   							                                                                                             
***	  published in: Erkenntnis																								 
***																															 
***   ---   Main Do-File   ---                                                                                               
***
***
***   Software:
***   Analyses run on Windows using Stata version 16 
***
***   Notes: 
***	  Data are stored in /data
***   Tables are outputted to /results/tables
***   Figures are outputted to /results/figures
***   To perform, a clean run delete the following folders: /results, /processed
***
***
********************************************************************************************************************************

*********************************
***   Set directory   		  ***
*********************************

*** Users must define global macro to point to the folder that contains the main do file

global anchoring "D:/Dropbox/Forschungsprojekte/Paper single peak and anchoring/repository/data-analysis/" 


* Confirm that the global for the project root directory was defined
assert !missing("$anchoring")

* Initialize log
clear
set more off
cap mkdir "$anchoring/scripts/logs"
cap log close
local datetime : di %tcCCYY.NN.DD!-HH.MM.SS `=clock("$S_DATE $S_TIME", "DMYhms")'
local logfile "$anchoring/scripts/logs/`datetime'.log.txt"
log using "`logfile'", text

* Configure Stata's library environment and record system parameters
run "$anchoring/scripts/programs/_config.do"

* Stata version control
version 16.1

* Create directories for output files
cap mkdir "$anchoring/results"
cap mkdir "$anchoring/results/figures"
cap mkdir "$anchoring/results/tables"
cap mkdir "$anchoring/processed"
cap mkdir "$anchoring/processed/baseline"
cap mkdir "$anchoring/processed/immodest"

* Run project analysis
do "$anchoring/scripts/0_data_preparation.do"
do "$anchoring/scripts/1_analysis_agent_level.do"
do "$anchoring/scripts/2_analysis_model_run_level.do"


* End log
di "End date and time: $S_DATE $S_TIME"
log close

exit